// pages/activeAddress/activeAddress.js
var $ = require('../util/commit.js');


Page({

  /**
   * 页面的初始数据
   */
  data: {
    address:'请选择',
    addressDetail:'',
    addressItem:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // 填写详细地址
  addressChange:function(e){
    let addrVal=e.detail.value;
    let that=this;
    that.setData({
      addressDetail:addrVal
    })
  },
  // 保存
  saveBtn:function(e){
    let that =this;
    console.log(that.data.addressItem);
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];

    prevPage.setData({
      address: that.data.address,
      type:2,
      typeVal:'线下活动',
      detailed_address: that.data.addressDetail,
      address_x: that.data.addressItem.location.lng,
      address_y: that.data.addressItem.location.lat,
    })
    prevPage.loadTypeData();
   
    wx.navigateBack();

  },
  // ToAddrSelect
  ToAddrSelect:function(e){
    $.openWin({
      url:'../addrSelect/addrSelect'
    })
  }
})